<template>
	<view class="f24r col363636">
		<view class="pt10r pl10r borB1SE8e8e8">
			<button class="w160r borRad10r lh70r colFff f26r disInBlo backCol409EFF"
				@click="cliAddCleaning"
			>
				新增保洁
			</button>
		</view>
		<view class="pl20r pr20r">
			<view class="mt20r borRad10r bSha0010u0rgb00001 backImgLiGrTBDeedfdaFff overHid"
				v-for="item in tempList" :key="item.id" @click="goCleaningDetail(item)"
			>
				<view class="f26r foWeiBold lh70r pl20r pr20r">
					<text class="col7a7a7a foWeiNor">
						保洁账号：
					</text>
					{{item.username}}
				</view>
				<view class="f26r foWeiBold lh70r pl20r pr20r">
					<text class="col7a7a7a foWeiNor">
						保洁名：
					</text>
					{{item.name}}
				</view>
				<view class="pl20r pr20r">
					<view class="disFlex lh70r">
						<view :class="'flex1 ' + (item.is_bind == 1 ? 'colC72d21' : 'col47ce68')">
							<text class="col7a7a7a">
								微信：
							</text>
							{{
								item.is_bind == 1 ? '未绑定' :
								item.is_bind == 2 ? '已绑定' : item.is_bind
							}}
						</view>
						<view :class="'flex1 teAliRight ' + (item.type == 1 ? 'col47ce68' : 'colC72d21')">
							<text class="col7a7a7a">
								启用/禁用：
							</text>
							{{
								item.type == 1 ? '启用' :
								item.type == 2 ? '禁用' : item.type
							}}
						</view>
					</view>
				</view>
			</view>
			<view class="lh100r teAliCenter col999" v-if="tempList.length">
				已加载全部
			</view>
			<view class="lh100r teAliCenter col999" v-if="tempList.length == 0">
				暂无数据
			</view>
		</view>
	</view>
</template>
<script>
import { inquiryToLogin } from '@/utils/utils.js'
import { getTeaCleanList } from '@/utils/api.js'
export default {
	data() {
		return {
			token: '',
			tempList: [],
		}
	},
	onShow() {
		inquiryToLogin().then(res => {
			this.token = res;
			this.getDataList1();
		});
	},
	onPullDownRefresh() {
		this.getDataList1(() => {
			uni.stopPullDownRefresh();
		});
	},
	methods: {
		getDataList1(callBack) {
			uni.showLoading({ title: '加载中...' })
			getTeaCleanList({token: this.token}).then(res => {
				console.log(res)
				if(res.data && res.data.length) {
					this.tempList = res.data;
				}
				uni.hideLoading();
				if(callBack) callBack();
			})
		},
		cliAddCleaning() {
			uni.navigateTo({ url: '/pages/index/addCleaningDetail?type=1' })
		},
		goCleaningDetail(item) {
			uni.navigateTo({
				url: '/pages/index/addCleaningDetail?type=2&item=' + JSON.stringify(item)
			})
		}
	}
}
</script>
<style>
</style>